<?php


namespace app\admin\model;

use think\Model;

class AdminUser extends Model {

    protected $pk='admin_id';

    // 管理员列表
    public function getAdminList($where, $listRows=10,$params=[]){

        return $this->where($where)->order('role_id desc')->paginate($listRows,false,['query'=>$params]);
    }


    // 写入一条数据
    public function insertOne($data){
        $data['create_time'] = $time = time();
        $data['update_time'] = $time;
        $data['is_del'] = 0;
        return $this->insertGetId($data);
    }

    // 获取一条数据 根据主键
    public function getOne($admin_id){

        return $this->where($this->pk,'=',$admin_id)->findOrFail();
    }

    // 软删除一条数据
    public function delOne($admin_id){
        $data['update_time'] = time();
        $data['is_del'] = 1;
        return $this->where($this->pk,'=',$admin_id)->update($data);
    }

    // 更新一条数据
    public function updateOne($admin_id,$data){
        $data['update_time'] = time();
        return $this->where($this->pk,'=',$admin_id)->update($data);
    }


}